package com.xju.ikun.service.serviceImpl;

import com.xju.ikun.bean.ListsBean;
import com.xju.ikun.bean.UserlistBean;
import com.xju.ikun.dao.ListsDao;
import com.xju.ikun.dao.UserlistDao;
import com.xju.ikun.service.ListsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ListsServiceImpl implements ListsService {
    @Autowired
    private ListsDao listsDao;
    @Autowired
    private UserlistDao userlistDao;

    @Override
    public ListsBean findByListid(int listid) {
        {return listsDao.findByListid(listid);}
    }

    @Override
    public List<ListsBean> findByUserid(int userid) {
        List<UserlistBean> userlistBeans = userlistDao.findByUserid(userid);
        List<ListsBean> listsBeans = new ArrayList<ListsBean>();
        for (UserlistBean m1 : userlistBeans) {
            int a = m1.getUserlist_listid();
            ListsBean listsBean = listsDao.findByListid(a);
            listsBeans.add(listsBean);
        }
        return listsBeans;
    }
    @Override
    public List<ListsBean> findAll() {
        return listsDao.findAll();
    }

    @Override
    public int insertListsBean(ListsBean listsBean) {
        return listsDao.insertListsBean(listsBean);
    }

    @Override
    public int updateByPrimaryKey(ListsBean listsbean) {
        return listsDao.updateByPrimaryKey(listsbean);
    }

    @Override
    public int deleteByPrimaryKey(int lid) {
        return listsDao.deleteByPrimaryKey(lid);
    }

}
